Coverage Report

Created: 2026-11-19 22:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
D:\a\cssh-rs\cssh-rs\cssh-rs-protocol\src\v1\handshake.rs
Line
Count
Source
1
//! The `Hello` / `Welcome` connection handshake.
2
3
use serde_derive::{Deserialize, Serialize};
4
5
use crate::v1::limits::DEFAULT_MAX_FRAME_LEN;
6
use crate::v1::version::{ProtocolVersion, Role};
7
8
/// First message each endpoint sends immediately on connect.
9
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10
pub struct Hello {
11
    /// Protocol version this endpoint speaks.
12
    pub protocol_version: ProtocolVersion,
13
    /// Whether the sender is the daemon or a client.
14
    pub role: Role,
15
    /// Process id of the sender.
16
    pub pid: u32,
17
    /// Capability flags this endpoint advertises: open-ended, opaque
18
    /// namespaced strings (e.g. `"paste"`) that peers intersect. Role-neutral,
19
    /// since both the daemon and a client send `Hello`.
20
    pub capabilities: Vec<String>,
21
    /// Largest CBOR frame body, in bytes, this endpoint is willing to receive.
22
    /// Peers take the minimum of the two advertised values as the send limit,
23
    /// so neither sends a frame the other would reject. Defaults to
24
    /// `DEFAULT_MAX_FRAME_LEN` for a peer that predates the field.
25
    #[serde(default = "default_max_frame_len")]
26
    pub max_frame_len: u32,
27
}
28
29
1
fn default_max_frame_len() -> u32 {
30
1
    return DEFAULT_MAX_FRAME_LEN;
31
1
}
32
33
/// Daemon's reply to a client's [`Hello`].
34
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
35
pub struct Welcome {
36
    /// Daemon-assigned identifier for this client.
37
    pub client_id: u64,
38
    /// Capability flags the daemon supports.
39
    pub server_capabilities: Vec<String>,
40
}
41
42
#[cfg(test)]
43
#[path = "../tests/v1/test_handshake.rs"]
44
mod tests;